#ifndef INPUTMANAGER_H
#define INPUTMANAGER_H

#include <OIS.h>
#include <Ogre.h>
class InputManager : public OIS::KeyListener, public OIS::MouseListener
{
public:
    InputManager();
    void initialise(Ogre::RenderWindow *rw);
    void capture();
    void setWindowSize(int w, int h);
    bool addKeyListener(OIS::KeyListener *kl, std::string name);
    bool addMouseListener (OIS::MouseListener *ml, std::string name);
    bool removeKeyListener(std::string name);
    bool removeMouseListener(std::string name);
    void removeAllKeyListeners();
    void removeAllMouseListeners();
    bool releaseMouse();
    bool grabMouse();
    OIS::KeyCode getKeyCode(std::string name);
protected:
    bool keyPressed(const OIS::KeyEvent &evt);
    bool keyReleased(const OIS::KeyEvent &evt);
    bool mouseMoved(const OIS::MouseEvent &evt);
    bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
    bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
private:
    void createKeyMap();
    std::map<std::string, OIS::KeyCode> keys;
    std::map<std::string, OIS::KeyListener*> keyListeners;
    std::map<std::string, OIS::MouseListener*> mouseListeners;
    OIS::InputManager *inputManager;
    OIS::Mouse *mouse;
    OIS::Keyboard *keyboard;
    int width, height;
};

#endif
